import { ref, onMounted, watch } from "vue"
import { useRoute } from "vue-router"
import { getCategoryAPI } from "@/apis/category"

export function useCategory() {
    const categoryData = ref({});
    const route = useRoute();
    const getCategory = async () => {
        const res = await getCategoryAPI(route.params.id);
        categoryData.value = res.data.result;
        console.log("222222",res);
    }
    onMounted(() => getCategory());
    watch(route, () => getCategory())
    return {
        categoryData
    }
}